home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gcc / ixemul_src.lha / ixemul-41.0 / static / xmalloc.c < prev   
C/C++ Source or Header  |  1994-08-19  |  1KB  |  55 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #include <string.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23.  
  24. static void volatile oom (void) asm ("Loom");
  25.  
  26. void *
  27. xmalloc (size_t size)
  28. {
  29.   void *res = malloc (size);
  30.   
  31.   if (res)
  32.     return res;
  33.     
  34.   oom ();
  35. }
  36.  
  37. void *
  38. xrealloc (void *buf, size_t size)
  39. {
  40.   void *res  = realloc (buf, size);
  41.   
  42.   if (res)
  43.     return res;
  44.  
  45.   oom ();
  46. }
  47.  
  48.  
  49. static void volatile 
  50. oom (void)
  51. {
  52.   fprintf (stderr, "Out of memory!\n");
  53.   exit (1);
  54. }
  55.